#include "mytime2.h"

Mytime::Mytime()
{
	/* 成员变量初始化，并将其挂靠到父窗口this */
	label = new QLabel(this);
	btn = new QPushButton("getTime",this);

	/* 调整成员变量位置 */
	this->resize(500,300);
	label->resize(100,100);
	label->move(250,100);
	btn->move(250,200);
	
	QObject::connect(btn, SIGNAL(clicked()),
		this,  SLOT(getTime()));
	
	QObject::connect(this, SIGNAL(mySig(QString)),
		label,  SLOT(setText(QString)));	
};

Mytime::~Mytime()
{
	delete(label);
	delete(btn);
};

void Mytime::getTime()
{
	/* 获取当前时间 */
	QString timestr = QTime::currentTime().toString("H:m:s a");
	emit mySig(timestr);
	
};
